package com.yps.io.nio;

/**
 * @author yps
 * NIO 服务端启动
 */
public class Server {
	private static int DEFAULT_PORT = 12344;
	private static ServerHandle serverHandle;
	 
	public static void start(){
		//默认方法传默认端口
		start(DEFAULT_PORT);
	}

	public static synchronized void start(int port) {
		//带参数方法
		if(serverHandle != null){
			serverHandle.stop();
		}
		serverHandle = new ServerHandle(port);
		new Thread(serverHandle,"Server").start();
		
	}
	public static void stop(){
		if(serverHandle != null){
			serverHandle.stop();
		}
	}
	public static void main(String[] args) {
		start();
	}
	
}
